package com.sise.aio和bio和nio.nio.基于nio的一个通信案例;

import java.io.IOException;
import java.net.InetAddress;
import java.net.InetSocketAddress;
import java.nio.ByteBuffer;
import java.nio.channels.SocketChannel;
import java.util.TreeMap;

public class NioClient2 {

    public static void main(String[] args) throws IOException, InterruptedException {
        SocketChannel socketChannel = SocketChannel.open();
        socketChannel.connect(new InetSocketAddress(InetAddress.getLocalHost(),9000));
        socketChannel.configureBlocking(false);
        while(true){
            socketChannel.write(ByteBuffer.wrap("this is a test".getBytes()));
            Thread.sleep(1000);
            System.out.println("------");
        }
    }
}
